<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="姓名">
				<j-input placeholder="请输入姓名模糊查询" v-model="queryParam.userName"></j-input>
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="等级">
              <a-select v-model="queryParam.grade" placeholder="请选择等级">
                <a-select-option value="">全部</a-select-option>
                <a-select-option value="1">高级</a-select-option>
                <a-select-option value="2">金牌</a-select-option>
                <a-select-option value="3">钻石</a-select-option>
                <a-select-option value="4">明星</a-select-option>
                <a-select-option value="5">首席</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
		  <a-col :xl="6" :lg="7" :md="8" :sm="24">
		    <a-form-item label="是否申请升级">
		      <a-select v-model="queryParam.authStatus" placeholder="请选择">
		        <a-select-option value="0">否</a-select-option>
		        <a-select-option value="1">是</a-select-option>
		      </a-select>
		    </a-form-item>
		  </a-col>
		  <a-col :xl="6" :lg="7" :md="8" :sm="24">
		    <a-form-item label="手机号">
				<a-input placeholder="请输入手机号" v-model="queryParam.phoneNum"></a-input>
		    </a-form-item>
		  </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <!-- <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('月嫂基础信息')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div> -->

    <!-- table区域-begin -->
    <div>
     <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
		 @change="handleTableChange">

        <span slot='gradeSlot' slot-scope='text,record'>
          <a-tag v-for='(ite,idx) in gradeList' :color='ite.color' v-if='text.grade == ite.value'>{{ite.name}}</a-tag>
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">详情</a>
          <template v-if="record.grade < 3 && record.authStatus == 1" >
			  <a-divider type="vertical"/>
			  <a @click="handleChanqestatus(record,0)" >审核升级通过</a>
			  <a-divider type="vertical" />
			  <a @click="handleChanqestatus(record,1)">审核升级不通过</a>
			  <a-divider type="vertical" />
		  </template>
		  <!-- <a-divider type="vertical" />
		  <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
		    <a>删除</a>
		  </a-popconfirm> -->
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <wechatNannyBaseinfo-modal ref="modalForm"></wechatNannyBaseinfo-modal>

    <trans-flow-table ref="flowForm"></trans-flow-table>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import WechatNannyBaseinfoModal from './modules/WechatNannyBaseinfoModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import TransFlowTable from './modules/TransFlowTable'
 import { getAction } from '@/api/manage'
  export default {
    name: "NannyBaseinfoList",
    mixins:[JeecgListMixin],
    components: {
      WechatNannyBaseinfoModal,
      TransFlowTable
    },
    data () {
      return {
        description: '月嫂基础信息管理页面',
		superQueryFieldList: [
		  { type: 'input', value: 'nickName', text: '昵称', },
		],
        // 表头
        columns: [
          // {
          //   title: '#',
          //   dataIndex: '',
          //   key:'rowIndex',
          //   width:60,
          //   align:"center",
          //   customRender:function (t,r,index) {
          //     return parseInt(index)+1;
          //   }
          //  },
		   {
            title: '姓名',
            align:"center",
            dataIndex: 'userName'
           },
          {
            title: '等级',
            align:"center",
            scopedSlots: { customRender: 'gradeSlot' },
          },

		   {
            title: '手机号',
            align:"center",
            dataIndex: 'phoneNum'
           },
          {
            title: '年龄',
            align:"center",
            dataIndex: 'age'
          },
		   {
            title: '可提现金额',
            align:"center",
            dataIndex: 'withdrawableMoney'
           },
		   {
            title: '已提现金额',
            align:"center",
            dataIndex: 'withdrawnMoney'
           },
		   {
            title: '押金',
            align:"center",
            dataIndex: 'deposit'
           },
		   {
		    title: '首次审核通过时间',
		    align:"center",
		    dataIndex: 'approvedTime'
		   },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
		url: {
          list: "/wechat/wechatNannyBaseinfo/list",
		  delete: "/wechat/wechatNannyBaseinfo/delete",
          changeStatus: "/wechat/wechatNannyBaseinfo/changeStatus",
          deleteBatch: "/wechat/wechatNannyBaseinfo/deleteBatch",
          exportXlsUrl: "wechat/wechatNannyBaseinfo/exportXls",
          importExcelUrl: "wechat/wechatNannyBaseinfo/importExcel",
       },
        gradeList:[
          {name:'高级',value:'1',color:'pink'},
          {name:'金牌',value:'2',color:'blue'},
          {name:'钻石',value:'3',color:'orange'},
          {name:'明星',value:'4',color:'green'},
          {name:'首席',value:'5',color:'cyan'},
        ]
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
    methods: {
      //查看交易流水详情
      transFlowInfo(record){
        this.$refs.flowForm.show(record);
      },
      handleChanqestatus(record,status){
      	const that = this
      	let title = status == 0 ?'确定审核通过?':'确定审核不通过?'
      	this.$confirm({
      	  title:title ,
      	  centered: true,
      	  onOk () {
      	    getAction(that.url.changeStatus,{nannyId:record.id,status}).then(res => {
      	    	if(res.code == 200) {
      				that.$message.success(status == 0 ?'审核通过':'审核不通过');
      	    		that.loadData();
      	    	}
      	    })
      	  }
      	})
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>